package com.xfsong.demo.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/books")
public class BooksController {
    //定义列表查询接口

    @Operation(summary = "获取图书列表信息", description = "获取图书列表信息")
    @GetMapping("/list")
    public String list(@Parameter(description = "页码", required = true) @RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "10") int size) {
        return "Books list";
    }

    //定义新增接口
    @PostMapping("/add")
    public String add(@RequestParam("name") String name, @RequestParam("author") String author) {
        System.out.println("name = " + name + ", author = " + author);
        return "Add book success";
    }

    @GetMapping("/{id}")
    public String get(@PathVariable("id") int id) {
        System.out.println("id = " + id);
        return "Get book success";
    }
}
